// 獐子岛
insheet using ./data/fd_risk.csv, clear
giveme indraw
keep if stkcd == 002069
rename accper year
replace year = substr(year, 1, 4)
destring year, replace
drop if year == 2020
rename year 年份
rename fd_risk 财务困境风险
twoway connected 财务困境风险 年份, graphregion(color(white)) scheme(s2mono) msymbol(circle)

// 康得新
insheet using ./data/fd_risk.csv, clear
giveme indraw
keep if stkcd == 002450
rename accper year
replace year = substr(year, 1, 4)
destring year, replace
rename year 年份
rename fd_risk 财务困境风险
twoway connected 财务困境风险 年份, graphregion(color(white)) scheme(s2mono) msymbol(circle)

// 东方园林
insheet using ./data/fd_risk.csv, clear
giveme indraw
keep if stkcd == 002310
rename accper year
replace year = substr(year, 1, 4)
destring year, replace
drop if year == 2012
drop if year == 2020
rename year 年份
rename fd_risk 财务困境风险
twoway connected 财务困境风险 年份, graphregion(color(white)) scheme(s2mono) msymbol(circle)


generate group = 0
sort fd_risk
replace group = 1 if _n < 0.1 * _N
replace group = 2 if _n > 0.9 * _N

sort group
forvalues gap = 5 (5) 720 {
    by group: egen mBHAR`gap' = mean(BHAR`gap')
}
keep group mBHAR*
duplicates drop

tostring group,replace
replace group = "group" + group
sxpose, firstnames clear force
destring *, replace
generate id = _n * 5
twoway (line group0 id) (line group1 id) (line group2 id), xline(240) graphregion(color(white)) scheme(s2mono)

